# 1-1-1
# int float bool str
# 1-1-2
# print(int(123))
# print(str(100))
# 1-1-3
# name=input('输入姓名：')
# price=float(input('输入苹果的单价:'))
# weight=int(input('输入苹果的重量'))
# all=price*weight
# print(f'{name}买了{weight}斤苹果，单价为{price}元，总价格为{all}元')
# 1-2
# name=input('输入姓名：')
# if name=='admin':
#     print(name)
# else:
#     print("用户名错误!")

# 2-1-1
# x=int(input('输入一个有效的年份:'))
# if (x%4==0 and x%100 !=0) or x%400==0:
#     print(f'{x}年是闰年')
# else:
#     print(f'{x}年不是闰年')

# 2-1-2
# name=input('输入用户名')
# if name=='tom':
#     age=int(input("输入年龄"))
#     if age<30:
#         print('小鲜肉')
#     else:
#         print('老腊肉')
# else:
#     print('输入用户名有误！')

# 2-1-3
# import random
# x=random.randint(1,100)
# while True:
#     y=int(input('用户输入数字'))
#     if x==y:
#         print(f'恭喜你猜中了，数字是 {y}')
#         break
#     elif y>x:
#         print(f'猜测的数字太大了，继续加油')
#         continue
#     else:
#         print(f'猜测的数字有点小，再来一次')

# 2-2
# list=["Web自动化", "UI自动化", "接口自动化"]
# list1=["Web自动化", "UI自动化", "接口自动化"]
# list.append("APP自动化")
# list1.append([1, 2, 3])
# print(list)
# print(list1)

# 3-1-1
# my_list = ["hello", "python", "hello", "itcast", "hello"]
# my_list.append("heima")
# my_list.pop(-1)
# my_list[-1]="chuanzhi"
# print(my_list[1])
# print(my_list.count('hello'))
# print(len(my_list))

# 3-1-2
# info = {'name':'mike', 'age':35, 'city':'sz'}
# info['sex']='man'
# info.pop('sex')
# info['age']=18
# print(info.get('name'))

# 3-1-3
# str='a-bc-12----3'
# print(str.count('-'))
# i=0
# for x in str:
#     if x=="-":
#         i+=1
# print(f'有{i}个字符"-"')

# 3-2
# def sum(a,b):
#     sum=a+b
#     return sum
# print(sum(4, 45))

# 4-1-1
# info_list = [{'name': 'mike', 'pwd': '123321'},
#              {'name': 'rock', 'pwd': 'abccba'},
#              {'name':'tom', 'pwd':'h321'}]
# for x in info_list:
#     name=x.get('name')
#     pwd=x.get('pwd')
#     print(f'用户名为：{name}, 密码为：{pwd}')
#
# 4-1-2
# def count_str_empty(x):
#     y=x.count(' ')
#     return y
# ret = count_str_empty('hello py, hello tom, hello mike')
# print(ret)

# 4-1-3
# def run(x):
#     if (x % 4 == 0 and x % 100 != 0) or x % 400 == 0:
#         return True
#     else:
#         return False
# print(run(2018))

# 4-2
# def sum_numbers(*args):
#     sum=0
#     for x in args:
#         sum+=x
#     return sum
# print(sum_numbers(1, 1, 5, 100))

# 5-1-1
# sum=0
# for x in range(1,101):
#     sum+=x
# print(sum)

# 5-1-2
# def sum001(start,end):
#     sum=0
#     for x in range(start,end):
#         sum += x
#     return sum
# print(sum001(1, 100))

# 5-1-3
# user_list = [{'name': '张三', 'age': 18},
#              {'name': '李四', 'age': 19}]
# def show_stu_info():
#     print(f'-----学生列表信息-----')
#     i=0
#     for x in user_list:
#         i+=1
#         name=x.get('name')
#         age=x.get('age')
#         print(f'{i}\t{name}\t{age}')
#     print(f'----------------------')
# show_stu_info()

# 5-2
class Cat:
    def __init__(self,name):
        self.name=name
    def eat(self):
        print(f'{self.name}爱吃鱼')

x=Cat('猫')
x.eat()